#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int T,n,m,L,V,d[100001],p[100001],ndcnt,nex[1000002],bac[1000002];//nex to p
ld a[100001],v[100001],pwV;
int ans1,ans2;
struct node{
    int l,r;
}nd[100001];
bool cmp(node x,node y){return x.r<y.r;}
int main(){
    ios::sync_with_stdio(false);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        ndcnt=ans1=ans2=0;
        memset(nex,0,sizeof(nex));
        memset(bac,0,sizeof(bac));
        cin>>n>>m>>L>>V;
        pwV=V*V;
        for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)cin>>p[i],nex[p[i]]=i,bac[p[i]]=i;
        if(!nex[L])nex[L]=-1;
        for(int i=L-1;i>=0;i--){
            if(!nex[i])nex[i]=nex[i+1];
        }
        if(!bac[0])bac[0]=-1;
        for(int i=1;i<=L;i++){
            if(!bac[i])bac[i]=bac[i-1];
        }
        for(int i=1;i<=n;i++){
            if(nex[d[i]]==-1)continue;
            if(a[i]<0){
                if(v[i]*v[i]<=pwV)continue;
                ld x=(pwV-v[i]*v[i])/(2*a[i]);
                if(x+d[i]>L)x=L-d[i];
                int c=bac[(int)(x+d[i])];
                if(c!=-1&&p[c]>=d[i])nd[++ndcnt]={nex[d[i]],c},ans1++;
            }
            else if(a[i]==0){
                if(v[i]*v[i]<=pwV)continue;
                nd[++ndcnt]={nex[d[i]],m},ans1++;
            }
            else{
                ld x,c;
                if(v[i]*v[i]>pwV)x=0;
                else x=(pwV-v[i]*v[i])/(2*a[i]);
                if(x+d[i]>L)continue;
                if(x+d[i]==(int)(x+d[i]))c=nex[(int)(x+d[i])];
                else c=nex[(int)(x+d[i])+1];
                if(c!=-1)nd[++ndcnt]={c,m},ans1++;
            }
        }
        sort(nd+1,nd+ndcnt+1,cmp);
        int lt=-1;
        for(int i=1;i<=ndcnt;i++){
            if(lt<nd[i].l){
                ans2++;
                lt=nd[i].r;
            }
        }
        cout<<ans1<<' '<<m-ans2<<endl;
    }
    return 0;
}
